package cn.zxcoder;

import cn.zxcoder.Tools.ToolUtil;
import cn.zxcoder.entity.pay.Order;
import cn.zxcoder.service.IOrderService;
import cn.zxcoder.service.impl.OrderServiceImpl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.toolkit.SimpleQuery;
import com.baomidou.mybatisplus.generator.FastAutoGenerator;
import com.baomidou.mybatisplus.generator.config.OutputFile;
import com.baomidou.mybatisplus.generator.engine.FreemarkerTemplateEngine;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.*;

public class Generator {


    @Test
    public  void gen() {
        FastAutoGenerator.create("jdbc:mysql://localhost:3306/crm_prod_2023", "root", "260016")
                .globalConfig(builder -> {
                    builder.author("zx") // 设置作者
                            .enableSwagger() // 开启 swagger 模式
                            .fileOverride() // 覆盖已生成文件
                            .outputDir("D:\\javasoft\\Project-one\\project\\src\\main\\java\\"); // 指定输出目录
                })
                .packageConfig(builder -> {
                    builder.parent("cn") // 设置父包名
                            .moduleName("zxcoder") // 设置父包模块名
                            .pathInfo(Collections.singletonMap(OutputFile.xml, "D:\\javasoft\\Project-one\\project\\src\\main\\resources\\mapper")); // 设置mapperXml生成路径
                })
                .strategyConfig(builder -> {
                    builder.addInclude("user_behavior")// 设置需要生成的表名
                            .addTablePrefix("user"); // 设置过滤表前缀
                })
                .templateEngine(new FreemarkerTemplateEngine()) // 使用Freemarker引擎模板，默认的是Velocity引擎模板
                .execute();

    }

    @Test
    public  void getMethodName() {
        System.out.println(Calendar.getInstance().get(Calendar.DAY_OF_MONTH));

//        IOrderService iOrderServiceIml = new OrderServiceImpl();
//        QueryWrapper<Order> wrapper = new QueryWrapper<>();
////        wrapper.select("count(*) as count");
////        wrapper.groupBy("month(addTime)");
//        wrapper.eq("dept_id", 9);



//        QueryWrapper<Order> queryWrapper = new QueryWrapper<>();
//        queryWrapper.select("addTime");
//                .groupBy("month(addTime)");
//        List<Map<String, Object>> mapList = iOrderServiceIml.listMaps(queryWrapper);
//        List<Order> list = iOrderServiceIml.list(queryWrapper);
//        System.out.println(list);







//        List<Map<String, Object>> list = iOrderServiceIml.listMaps(wrapper);//获取了相应条件下的所有订单数据
//        List<Order> list1 = iOrderServiceIml.list(wrapper);
//        System.out.println(list1);
////        for (Map<String, Object> stringObjectMap : list) {
////            stringObjectMap.keySet().forEach(System.out::println);
////            stringObjectMap.values().forEach(System.out::println);
////            System.out.println("===========================");
////        }
    }
}
